<template>
  <div>
    <el-card v-for="(value,index) in names">
      {{ value }}
    </el-card>
    <br/>
    <el-card v-for="(value,index) in scores">
      {{ value }}
    </el-card>
  </div>
</template>

<script>
import {serverIp} from "../../public/config";

export default {
  name: "MyScore",
  data() {
    return {
      serverIp: serverIp,
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      names: [],
      scores: []
    }
  },
  created() {
    this.load1() // 课程
    this.load2() // 分数
  },
  methods: {
    load1() {
      this.request.get("/score/names", {
        params: {
          uid: this.user.id
        }
      }).then(res => {
        if (res.data != null) {
          this.names = res.data
        }
      })
    },
    load2() {
      this.request.get("/score/scores", {
        params: {
          uid: this.user.id
        }
      }).then(res => {
        this.scores = res.data
      })
    }
  }
}
</script>

<style scoped>
.el-card {
  width: 10%;
  display: inline-block;
}
</style>